<?php
/**
 * Created by PhpStorm.
 * Admininfo: Administrator
 * Date: 2018/3/21
 * Time: 15:35
 */
namespace app\admin\controller;
use app\common\controller\Curt;
use Library\Utils;
use think\Db;

class  Column extends Curt {
    public function __construct($upload = false, array $uploadsConfig = ['input_name' => 'coverFile', 'data_field' => 'cover'])
    {
        parent::__construct($upload = true,$uploadConfig = array(
            'input_name' => 'coverFile',//文本框name
            'data_field' => 'cover'//数据库字段
        ));
    }

    public function getall()
    {
        $keyword=input('get.keyword');
        if($keyword){
            $where['name']=['like','%'.$keyword.'%'];//模糊查询or可以一个条件中写多个字段以‘|’分开
        }
        $list = $this->model
            ->order('id desc')
            ->where($where)
            ->paginate();
        $page = $list->render();
        $this->assign('list', $list);
        $this->assign('page', $page);
    }
    public function showAdd()
    {
        $where['status']=1;
        $where['id']=['neq',8];
        $list=Db::name('column')->where($where)->select();
        $list= Utils::toTrees($list,'column_id');
        $this->assign('list', $list);
       return $this->fetch();
    }
    public function showEdit($id)
    {
        $list=Db::name('column')->where('status',1)->select();
        $list= Utils::toTrees($list,'column_id');

        $this->assign('list', $list);
        return parent::showEdit($id); // TODO: Change the autogenerated stub
    }

}